<%@ page contentType="text/html; charset=UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>菜单</title>
<link rel="stylesheet" type="text/css" href="${pageContext.servletContext.contextPath}/jquery-easyui/themes/default/easyui.css">
<link rel="stylesheet" type="text/css" href="${pageContext.servletContext.contextPath}/jquery-easyui/themes/icon.css">
<script type="text/javascript" src="${pageContext.request.contextPath}/jquery-easyui/jquery.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/jquery-easyui/jquery.easyui.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/jquery-easyui/locale/easyui-lang-zh_CN.js"></script>
<script type="text/javascript">
  $(document).on('contextmenu', function (e) {
    e.preventDefault();
    $('#menu').menu('show', {
      left : e.pageX,
      top : e.pageY
    });
  })
  $(function () {
    // 查找id为menu的菜单的指定项
    var item = $('#menu').menu('findItem', '子菜单');
    $('#menu').menu('appendItem', {
      // 设置父菜单元素
      parent : item.target,
      text : '重新加载',
      iconCls : 'icon-reload',
      onclick : function () {
        window.location.reload();
      }
    });
    $('#menu').menu('appendItem', {
      parent: item.parent,
      text : '新菜单项',
      iconCls : 'icon-man',
      onclick : function () {
        console.log("新建的菜单项");
      }
    });
    //从jQuery的3.0版本开始，.bind()已弃用
    $("#back").on("click", function () {
      window.history.back();
    });
  })
</script>
</head>
<body>
  <div id="menu" class="easyui-menu" style="width: 120px">
    <div>菜单项</div>
    <div data-options="iconCls: 'icon-more'">
      <span>子菜单</span>
      <div style="width: 150px">
        <div>菜单项1</div>
        <div>菜单项2</div>
        <div>菜单项3</div>
      </div>
    </div>
    <!-- 分隔线 -->
    <div class="menu-sep"></div>
    <div id="back" data-options="iconCls: 'icon-back'">后退</div>
  </div>
</body>
</html>